Skip to content

Green tests on a fresh clone, ruff config, CI, and audit fixes - #1

Merged
techmore merged 2 commits into
mainfrom
improve/test-data-and-ci
Oct 21, 2026
Merged

techmore merged 2 commits into
mainfrom
improve/test-data-and-ci

Conversation

@techmore

Copy link
Copy Markdown
Owner

Summary

On a fresh clone the suite was red: 16 failed, 1 error, 14 skipped out of 215, every one of them a missing data/malecns-v1.0/* file, even though the README said circuit tests skip themselves. This PR makes the suite green without the ~1 GB MaleCNS download, adds lint configuration and GitHub Actions CI, and fixes a handful of real bugs found during the audit.

What changed

  • NOTFLYGUY_DATA_ROOT (notflyguy/paths.py): a single data_root() resolver, read at call time, replaces four hard-coded data/malecns-v1.0 paths (connectome, motor_training, circuit, habitat, wiring_control, train, DR fly_bridge). Missing-data errors now name the override.
  • Synthetic circuit (notflyguy/synthetic.py): writes a random graph, leg catalog and summary in exactly the measured file layout, flagged "synthetic": true. The test session writes one and points NOTFLYGUY_DATA_ROOT at it when the measured circuit is absent (tests/conftest.py), so the 29 formerly failing/skipped circuit tests run everywhere; if the real circuit is present it is used instead. python -m notflyguy.synthetic --root DIR also lets you boot the dashboard without the download.
  • CI (.github/workflows/ci.yml): ruff check plus pytest on Python 3.10/3.11/3.12, then a smoke boot of python -m notflyguy.server --no-body --no-replies against a synthetic circuit with a check on /api/state.
  • Ruff config in pyproject.toml (F, E4/E7/E9, W, B, I, UP; line length not enforced; DR adapter keeps its one-statement-per-line style) and ruff in the dev extra. First commit is purely ruff --fix output (import ordering, unused imports, collections.abc imports) plus two one-line manual fixes.
  • Security: dr_adapter/dashboard.py had no same-origin check on POST; /api/approve sends a real game command. Added the same Origin/Host check the main server already has, with tests.
  • Bug: Habitat._ingest_group_message iterated a bare-string aliases payload character by character, so "aliases": "notflyguy" marked almost every message as addressed. Now validated; regression test.
  • Bug: NOTFLYGUY_ID_SALT was documented in a comment but never read. Now honoured; test.
  • tests/test_server.py::test_handler_returns_503_without_a_habitat asserted nothing about the server; it now exercises every endpoint.
  • python -m notflyguy starts the server.
  • README: install table, data root, synthetic stand-in, tests/lint/CI, environment-variable reference.

How verified

$ python -m pytest -q
231 passed in 22.22s          # was: 16 failed, 184 passed, 14 skipped, 1 error
$ ruff check .
All checks passed!            # was: 102 findings (default rules), no config

Also ran the CI smoke step locally: python -m notflyguy.synthetic --root … then NOTFLYGUY_DATA_ROOT=… python -m notflyguy --no-body --no-replies --port 8766; /api/state reports circuit_loaded: true and / serves the dashboard. Python 3.12.15 (uv-managed; the system Python here is 3.14, outside requires-python).

Risks / follow-ups

  • ConnectomeState(root=None) and make_readout(root=None) now mean "resolve the default"; previously the default was a Path constant. DEFAULT_ROOT / DEFAULT_CATALOG_ROOT / DEFAULT_CIRCUIT_ROOT are kept as names for existing callers.
  • The synthetic circuit is random. Tests assert contracts (shapes, determinism, stability bound, labels), not biological results, so they are valid on either circuit; anything that reads motor-circuit.json can check synthetic.
  • NOTFLYGUY_ID_SALT is read once at import (so trainer, habitat and plugin agree); set it before starting the process.
  • Dependabot alerts are disabled on this repo; worth enabling.
  • A second PR with the dashboard UX pass follows.

🤖 Generated with Claude Code

techmore and others added 2 commits October 20, 2026 06:20
Adds [tool.ruff] to pyproject (pyflakes, pycodestyle errors, bugbear,
isort, pyupgrade; line length not enforced) and ruff to the dev extra.
Everything in this commit is ruff --fix output plus two one-line manual
fixes: a percent-format in train.py and a semicolon in a test. No
behaviour changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Before this, 16 tests failed and one errored on any clone that had not
run the ~1 GB MaleCNS bootstrap, contradicting the README's claim that
circuit tests skip themselves. Loaders hard-coded data/malecns-v1.0
relative to the package in four places with no way to redirect them.

- notflyguy/paths.py: one data_root() resolver, honouring a new
  NOTFLYGUY_DATA_ROOT variable read at call time. connectome,
  motor_training, circuit, habitat, wiring_control, train and the DR
  bridge all go through it; their missing-data errors now name the
  override.
- notflyguy/synthetic.py: writes a random circuit, catalog and summary
  in the measured file layout, flagged synthetic:true. The test session
  (tests/conftest.py) writes one and points NOTFLYGUY_DATA_ROOT at it
  when the measured circuit is absent, so the 29 formerly skipped or
  failing circuit tests now run everywhere. Also usable to start the
  dashboard without the download.
- .github/workflows/ci.yml: ruff + pytest on 3.10/3.11/3.12 and a
  dashboard smoke boot against a synthetic circuit.
- dr_adapter/dashboard.py: same-origin check on POST, matching the main
  server; /api/approve sends real game commands and had no CSRF defence.
- habitat: validate the aliases payload (a bare string was iterated per
  character, marking nearly every message as addressed).
- chatlog: NOTFLYGUY_ID_SALT was documented in a comment but never read.
- test_server: the 503-without-habitat test now exercises the server.
- python -m notflyguy starts the server.
- README: install table, data root, synthetic stand-in, tests/lint/CI,
  environment variable reference.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@techmore
techmore merged commit 961ac14 into main Oct 21, 2026
4 checks passed
@techmore
techmore deleted the improve/test-data-and-ci branch October 21, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant